<template>
  <el-container>
    <el-header>
      <el-menu mode="horizontal" :default-active="$route.path">
        <el-menu-item index="/" @click="goToHomePage">首页</el-menu-item>
        <el-menu-item index="/user" @click="goToUserPage">用户信息</el-menu-item>
      </el-menu>
    </el-header>

    <el-main>
      <router-view />
    </el-main>
  </el-container>
</template>

<script>
export default {
  name: 'App',
  methods: {
    goToHomePage(){
      this.$router.push('/home');
    },
    goToUserPage() {
      this.$router.push('/user');  // 手动触发跳转
    }
  }
};
</script>

<style scoped>
.el-header {
  background-color: #42b983;
}
</style>
